package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.TableDao;
import com.chhlz.module.base.model.DiningTable;
import com.chhlz.module.service.TableService;

@Service
public class TableServiceImpl implements TableService{
	@Autowired
	private TableDao tableDao;

	@Override
	public int save(DiningTable t) {
		return this.tableDao.save(t);
	}

	@Override
	public void update(DiningTable t) {
		this.tableDao.update(t);
	}

	@Override
	public void delete(int id) {
		DiningTable dt = this.tableDao.get(id);
		this.tableDao.delete(dt);
	}

	@Override
	public List<DiningTable> findAll(int page, int rows, String sort, String order) {
		return this.tableDao.findAll(page, rows, sort, order);
	}

	@Override
	public boolean isExist(String number) {
		boolean flag = false;
		String hql = "select * from DiningTable t where t.number=" + number;
		if(this.tableDao.find(hql).size()>0)
			flag = true;
		return flag;
	}

	@Override
	public int getTotal() {
		return this.tableDao.countAll();
	}

}
